package com.yamidragut.simpleebooksreader;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.widget.ImageView;
import android.widget.Toast;

public class ShowCoverActivity extends ActionBarActivity {
	
	private Bitmap cover;
	private ImageView coverView;
	private String coverPath;
		
	public static final String LOG = "ShowCoverActivity";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_show_cover);
		
		// Show the Up button in the action bar.
		ActionBar actionBar = getSupportActionBar();
		actionBar.setHomeButtonEnabled(true);
		
		// Get the absolute path
		Bundle extras = getIntent().getExtras();
		coverPath = extras.getString(Util.COVER_PATH_EXTRA);
		
		coverView = (ImageView) findViewById(R.id.cover_fullscreen_view);
		
		// Get the bitmap of the cover
		cover = FilesSaver.loadBitmapCoverFromStorage(coverPath);
		
		if(cover != null) { 
			coverView.setImageBitmap(cover);
		} else {
			Toast.makeText(this, getString(R.string.error_show_cover), Toast.LENGTH_LONG).show();
		}

	}
	

}
